package demo5_i;

class Outclass{
    public int data1;
    private int data2;
    private static  int data3;
    //静态内部类
    static class Innerclass{
        public int data4 = 10;
        public static int data5 = 5;
        public void test(){
            System.out.println("静态内部类方法");
        }
    }
}

class OutClass2{
    //内部类
    class InnerClass2{
        public void test(){
            System.out.println("实例内部类方法");
        }
    }
}

class Out{
    public void test1(){
        System.out.println("匿名内部类方法");
    }
}
interface IA{
    void test1();
}
public class Test {

    public static void main(String[] args) {
        IA a = new IA(){
            @Override
            public void test1(){
                System.out.println("IA接口");
            }
        };
        a.test1();
        /*new Out(){
            //匿名内部类
        }.test1();//也可以重写父类方法*/
    }

    public void testMethod() {
        //局部内部类
        class Inner {
            public void test() {
                System.out.println("局部内部类方法");
            }
        }
        Inner inner = new Inner();
        inner.test();
    }

    public static void main2(String[] args) {
        //实例化实例内部类
        OutClass2 outClass2 = new OutClass2();
        OutClass2.InnerClass2 innerClass2 = outClass2.new InnerClass2();
        innerClass2.test();
    }
    public static void main1(String[] args) {
        //实例化静态内部类
        Outclass.Innerclass innerclass = new Outclass.Innerclass();
        innerclass.test();
    }







}
